'use strict';

const Service = require('egg').Service;

class TokenService extends Service {

    async getToken(id) {
        const token = await this.app.jwt.sign({
            id: id
        }, this.config.jwt.secret);
        //缓存到redis
        await this.app.redis.set(token, id, "EX", this.config.redis.redisExpire)
        return token;
    }

}

module.exports = TokenService;